package com.example.activitytest;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class SecondActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
//        Intent intent=getIntent();
//        String data=intent.getStringExtra("extra_data");
//        Toast.makeText(this,data,Toast.LENGTH_LONG).show();

        Button button2=(Button) findViewById(R.id.buon2);
        button2.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                intent.putExtra("data_return","Hello FirstActivity");
                setResult(RESULT_OK,intent);
                finish();
            }
        });
    }

    @Override
    public void onBackPressed() {
//        super.onBackPressed();
        Intent intent=new Intent();
        intent.putExtra("data_return","Hello FirstActivity突突突");
        setResult(RESULT_OK,intent);
        finish();
    }
}